import java.io.IOException;
import java.util.Scanner;
import java.util.zip.Deflater;

//shutdown -r -t 55秒的重启
//shutdown -a 取消重启
//通过runtime提供的exec() 并返回一个Process对象
//用管理员身份运行cmd:
//禁用笔记本键盘 sc config i8042prt start= disabled
//启用笔记本键盘 sc config i8042prt start= auto
public class control {

    public static void main(String[] args) throws IOException {
//        Runtime.getRuntime().exec("TITLE 键盘控制");
        String shut = "sc config i8042prt start= disabled";
        String open = "sc config i8042prt start= auto";
        int choice = 0;
        Scanner scanner = new Scanner(System.in);
        System.out.println("该程序能修改笔记本自带键盘的状态5\n 1 关闭   2 启用 \n 需要注意的是该程序执行成功会默认重启" +
                "你的电脑，在10秒后");
        choice = scanner.nextInt();
        try {
            switch (choice) {
                case 1:
                    Process processShut = Runtime.getRuntime().exec(shut);
//                    Process processShut = Runtime.getRuntime().exec("calc");
                    System.out.println(processShut);
                    System.out.println("执行成功");

                    break;
                case 2:
                    Process processOpen = Runtime.getRuntime().exec(open);
                    System.out.println(processOpen);
                    System.out.println("执行成功");
                    break;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
